package com.lykj.modules.shop.znapi;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lykj.common.utils.HttpClient;
import com.lykj.common.utils.HttpClientResult;
import com.lykj.core.log.exception.ServiceException;
import com.lykj.core.tool.utils.Func;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

@Component
public class ZnApiUtils {

	//	public static String znApiUrl = "http://223.100.7.22:3220";//测试地址
//	public static String znApiUrl = "http://223.100.7.23:3220";//正式地址
	@Value("${lykj.zn.apiUrl}")
	public String znApiUrl;
	@Value("${lykj.shsy.shqyUrl}")
	public String shqyUrl;

	public static void main(String[] args) throws IOException {
//		ZnApiUtils znApiUtils = new ZnApiUtils();
//		znApiUtils.znApiUrl = "http://223.100.7.22:3220";//测试地址
//
//		File file = new File("D:\\50.xlsx");
//		FileInputStream fileInputStream = new FileInputStream(file);
//		MultipartFile mFile = new MockMultipartFile(file.getName(), file.getName(), ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
//		znApiUtils.protocolTradeImport("4a5178e8-1533-439b-9b38-af97aeca54ab","270000017",mFile);

		System.out.println(getRandomIp());
	}

	/**
	 * 注册时发送验证码
	 *
	 * @param mobilePhone 手机号,不允许为空
	 */
	public JSONObject sendRegisterVerifyCode(String mobilePhone) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			String ip = getRandomIp();
			headers.put("X-FORWARDED-FOR", ip);
			headers.put("CLIENT-IP", ip);
			Map<String, Object> params = new HashMap<>();
			params.put("mobilePhone", mobilePhone);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/register/sendVerifyCode", headers, params);
			System.out.println("注册时发送验证码>>>>>>>>>：" + result);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("注册时发送验证码>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("注册时发送验证码通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 设置新登录密码
	 *
	 * @param mobilePhone 手机号,不允许为空
	 * @param password    密码,不允许为空，客户端限制 6~18 位长度，字母+数字，需要在客户端对新密码进行 MD5 加密后传到服务端
	 * @param verifyCode  验证码,不允许为空
	 */
	public JSONObject resetLoginPwd(String mobilePhone, String password, String verifyCode) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			params.put("mobilePhone", mobilePhone);
			params.put("password", password);
			params.put("verifyCode", verifyCode);
			HttpClientResult result = httpClient.doPut(znApiUrl + "/customer/loginPassword/resetLoginPwd", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("设置新登录密码>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("设置新登录密码通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 忘记登录密码发送验证码
	 *
	 * @param mobilePhone 手机号,不允许为空
	 */
	public JSONObject sendVerifyCode(String mobilePhone) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			String ip = getRandomIp();
			headers.put("X-FORWARDED-FOR", ip);
			headers.put("CLIENT-IP", ip);
			Map<String, Object> params = new HashMap<>();
			params.put("mobilePhone", mobilePhone);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/loginPassword/sendVerifyCode", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("忘记登录密码发送验证码>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("忘记登录密码发送验证码通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 注册
	 *
	 * @param channel     签约渠道(签约渠道 1-APP 2-H5 3-公众号 4-小程序)
	 * @param mobilePhone 手机号,不允许为空
	 * @param password    密码,不允许为空，客户端限制 6~18 位长度，字母+数字，需要在客户端对新密码进行 MD5 加密后传到服务端
	 * @param verifyCode  验证码,不允许为空
	 */
	public JSONObject register(String channel, String mobilePhone, String password, String verifyCode) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			params.put("channel", channel);
			params.put("mobilePhone", mobilePhone);
			params.put("password", password);
			params.put("verifyCode", verifyCode);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/register/register", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("注册>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("注册通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 登录
	 *
	 * @param username 手机号
	 * @param password 密码,不允许为空，客户端限制 6~18 位长度，字母+数字，需要在客户端对新密码进行 MD5 加密后传到服务端
	 * @return
	 */
	public JSONObject loginByPwd(String username, String password) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			params.put("username", username);
			params.put("password", password);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/login/loginByPwd", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("登录>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("登录通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 修改昵称
	 *
	 * @param nickName 昵称
	 */
	public JSONObject updateNickName(String token, String userId, String nickName) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			params.put("nickName", nickName);
			HttpClientResult result = httpClient.doPut(znApiUrl + "/customer/common/updateNickName", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("修改昵称>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("修改昵称通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 修改手机号
	 *
	 * @param mobilePhone 手机号；明文
	 * @param verifyCode  手机验证码
	 */
	public JSONObject modifyMobilePhone(String token, String userId, String mobilePhone, String verifyCode) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			params.put("mobilePhone", mobilePhone);
			params.put("verifyCode", verifyCode);
			HttpClientResult result = httpClient.doPut(znApiUrl + "/customer/common/modifyMobilePhone", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("修改手机号>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("修改手机号通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 绑定手机号发送验证码
	 *
	 * @param mobilePhone 手机号；明文
	 */
	public JSONObject sendVerifyCode(String token, String userId, String mobilePhone) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			params.put("mobilePhone", mobilePhone);
			HttpClientResult result = httpClient.doPut(znApiUrl + "/customer/common/sendVerifyCode", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("绑定手机号发送验证码>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("绑定手机号发送验证码号通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 用户实名申请
	 *
	 * @param token
	 * @param userId
	 * @param params backDocument *证件照(反面)地址; 不允许为空
	 *               documentNumber *证件号码; 不允许为空
	 *               documentType *证件类型cardType; 不允许为空
	 *               frontDocument *证件照(正面)地址; 不允许为空
	 *               handDocument *证件照(手持)地址; 不允许为空
	 *               realName *真实姓名; 不允许为空
	 *               validity *证件有效期; 不允许为空，格式：yyyy-MM-dd
	 * @return
	 */
	public JSONObject authenticationApply(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/authentication/apply", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("用户实名申请>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("用户实名申请通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 上传实名申请证件照
	 *
	 * @param token
	 * @param userId
	 * @param file
	 * @return
	 */
	public JSONObject uploadApplyPhoto(String token, String userId, MultipartFile file) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
//			params.put("idPhoto", file);
			HttpClientResult result = httpClient.doPostFormFile(znApiUrl + "/customer/authentication/uploadApplyPhoto", "idPhoto", file, headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("上传实名申请证件照>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("上传实名申请证件照通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 实名查询
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject authenticationInfo(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/customer/authentication/info", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("实名查询>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("实名查询通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 设置/重置安全密码
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject fundPasswordReset(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPut(znApiUrl + "/customer/fundPassword/reset", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("设置/重置安全密码>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("设置/重置安全密码通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询个人信息
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject customerInfo(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/customer/common/info", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询个人信息>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询个人信息通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询收付款方式列表
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject accountManageList(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/base/transfer/offline/accountManage/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONArray.parseArray(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询收付款方式列表>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询收付款方式通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 添加收货地址
	 *
	 * @param token
	 * @param userId
	 * @param jsonObject
	 * @return
	 */
	public JSONObject shippingAddressAdd(String token, String userId, JSONObject jsonObject) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/shippingAddress/add", headers, jsonObject, "utf-8");
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("添加收货地址>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("添加收货地址通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 设为默认收货地址
	 *
	 * @param token
	 * @param userId
	 * @param addressId
	 * @return
	 */
	public JSONObject shippingAddressAsDefault(String token, String userId, String addressId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("addressId", addressId);
			HttpClientResult result = httpClient.doPut(znApiUrl + "/customer/shippingAddress/asDefault/" + addressId, headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("设为默认收货地址>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("设为默认收货地址通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 删除收货地址
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject shippingAddressDelete(String token, String userId, String addressId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doDelete(znApiUrl + "/customer/shippingAddress/delete/" + addressId, headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("删除收货地址>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("删除收货地址通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询收货地址列表
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject shippingAddressList(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/customer/shippingAddress/list", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询收货地址列表>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询收货地址列表通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 绑定银行账户
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject bindAccountBind(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/bindAccount/bind", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("绑定银行账户>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("绑定银行账户通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 解绑银行账户
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject bindAccountUnBind(String token, String userId, String id) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doDelete(znApiUrl + "/customer/bindAccount/unBind/" + id, headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("解绑银行账户>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("解绑银行账户通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询绑定银行账号
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject bindAccountList(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/customer/bindAccount/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONArray.parseArray(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询绑定银行账号>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询绑定银行账号通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 验证绑定信息
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject bindVerification(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPost(znApiUrl + "/customer/bindAccount/bindVerification", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("验证绑定信息>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("验证绑定信息通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 充值申请
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject recharge(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("requestAttach",JSONObject.parseObject("{\"subject\":\"充值\"}"));
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/transfer/online/recharge/recharge", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("充值申请>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("充值申请通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询充值列表
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	// {"content":"{"maxStandard":100000000000121,"minStandard":100000000000116,"list":[{"rechargeId":100000000000121,"userId":270000062,"amount":"1.00","payTypeId":1,"title":null,"description":null,"tradeOrderNO":null,"status":4,"gpayPayFlowID":null,"note":null,"gpayPayTime":null,"createTime":"2022-01-10 09:17:29"},{"rechargeId":100000000000120,"userId":270000062,"amount":"1.00","payTypeId":1,"title":null,"description":null,"tradeOrderNO":null,"status":4,"gpayPayFlowID":null,"note":null,"gpayPayTime":null,"createTime":"2022-01-07 17:14:15"},{"rechargeId":100000000000119,"userId":270000062,"amount":"1.00","payTypeId":1,"title":null,"description":null,"tradeOrderNO":null,"status":4,"gpayPayFlowID":null,"note":null,"gpayPayTime":null,"createTime":"2022-01-07 17:05:04"},{"rechargeId":100000000000118,"userId":270000062,"amount":"1.00","payTypeId":1,"title":null,"description":null,"tradeOrderNO":null,"status":3,"gpayPayFlowID":null,"note":null,"gpayPayTime":null,"createTime":"2022-01-07 15:42:50"},{"rechargeId":100000000000117,"userId":270000062,"amount":"1.00","payTypeId":1,"title":null,"description":null,"tradeOrderNO":null,"status":4,"gpayPayFlowID":null,"note":null,"gpayPayTime":null,"createTime":"2022-01-07 15:42:23"},{"rechargeId":100000000000116,"userId":270000062,"amount":"1.00","payTypeId":1,"title":null,"description":null,"tradeOrderNO":null,"status":4,"gpayPayFlowID":null,"note":null,"gpayPayTime":null,"createTime":"2022-01-07 15:35:28"}]}","status":200}
	public JSONObject rechargeList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("month", month);
//			params.put("offset", 100000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/transfer/online/recharge/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询充值列表>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询充值列表通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 提现申请
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject withdrawal(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			params.put("payeeAttach", JSONObject.toJSON(params.get("payeeAttach")));
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/transfer/online/withdrawal/withdrawal", headers, params);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("提现申请>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("提现申请通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询提现列表
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject withdrawalList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("month", month);
//			params.put("offset", 100000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/base/transfer/offline/withdrawal/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询提现列表>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询提现列表通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询用户余额
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject balanceQuery(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/base/finance/balanceQuery/query", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询用户余额>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询提现列表通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询买卖委托档位查询
	 *
	 * @param commodityId
	 * @return
	 */
	public JSONObject makerRecordSumInfo(String commodityId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
//			headers.put("Token", token);
//			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("bsFlag", 2);
			params.put("commodityId", commodityId);
			params.put("size", 1);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/tradeQuery/makerRecordSumInfo", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询买卖委托档位查询>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询买卖委托档位查询通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询商品可买量
	 *
	 * @param commodityId
	 * @return
	 */
	public JSONObject availableQuantity(String commodityId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
//			headers.put("Token", token);
//			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
//			params.put("commodityId", commodityId);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/trade/availableQuantity/" + commodityId, headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询商品可买量>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询商品可买量通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询是否签约
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject querySignContract(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/signContract/querySignContract", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询是否签约>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询是否签约通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 签约申请
	 *
	 * @param token
	 * @param userId
	 * @param callbackUrl
	 * @return
	 */
	public JSONObject signContract(String token, String userId, String callbackUrl) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("callbackUrl", Base64.getUrlEncoder().encodeToString(callbackUrl.getBytes(StandardCharsets.UTF_8)));
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/trade/signContract/signContractApply", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			} else {
				if (returnJson.getJSONObject("content").get("formString") != null) {
					BASE64Decoder decoder = new BASE64Decoder();
					try {
						String encodedText = returnJson.getJSONObject("content").getString("formString");
						returnJson.put("html", new String(decoder.decodeBuffer(encodedText), "UTF-8").replaceAll("\\\\", ""));
					} catch (Exception e) {
					}
				}
			}
			System.out.println("签约申请>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("签约申请通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 签约协议确认
	 *
	 * @param token
	 * @param userId
	 * @param channel
	 * @return
	 */
	public JSONObject registerSure(String token, String userId, String channel) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("channel", channel);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/trade/signContract/registerSure", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("签约协议确认>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("签约协议确认通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 摘单
	 *
	 * @param token
	 * @param userId
	 * @param jsonObject
	 * @return
	 */
	public JSONObject tradeBatch(String token, String userId, String commodityId, JSONObject jsonObject) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			headers.put("Content-Type", "application/json");
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/trade/trade/tradeBatch/" + commodityId, headers, jsonObject, "utf-8");

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("摘单>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("摘单通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询订单
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject tradeList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("offset", 1000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/tradeQuery/trade/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询订单>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询订单通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询历史订单
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject tradeListHis(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("offset", 1000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/tradeQuery/trade/listHis", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询历史订单>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询历史订单通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 申请交收
	 *
	 * @param token
	 * @param userId
	 * @param jsonObject
	 * @return
	 */
	public JSONObject deliveryApply(String token, String userId, JSONObject jsonObject) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPost(znApiUrl + "//sale/delivery/delivery/apply", headers, jsonObject);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("申请交收>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("申请交收通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查找交收申请信息
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject deliveryList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("offset", 1000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/delivery/delivery/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查找交收申请信息>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查找交收申请信息通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 确认收货
	 *
	 * @param token
	 * @param userId
	 * @param deliveryApplyId deliveryApplyId
	 * @return
	 */
	public JSONObject deliveryConfirmReceipt(String token, String userId, String deliveryApplyId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
//			params.put("deliveryApplyId", deliveryApplyId);
			HttpClientResult result = httpClient.doPut(znApiUrl + "/sale/delivery/delivery/confirmReceipt/" + deliveryApplyId, headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("确认收货>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("确认收货通信失败，请稍后重试或联系客服!");
		}
	}

	/***************************************************************************商品和卖出接口*****************************************************************************/

	/**
	 * 经理人协议交易数据导入
	 *
	 * @param token
	 * @param userId
	 * @param file
	 * @return
	 */
	public JSONObject protocolTradeImport(String token, String userId, MultipartFile file) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
//			params.put("file", file);
			HttpClientResult result = httpClient.doPostFormFile(znApiUrl + "/sale/trade/protocolTrade/import", "file", file, headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			System.out.println("经理人协议交易数据导入>>>>>>>>>：" + result.getContent());
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("经理人协议交易数据导入>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("经理人协议交易数据导入通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 经理人导入数据提交
	 *
	 * @param token
	 * @param userId
	 * @param batchNo
	 * @return
	 */
	public JSONObject protocolTradeSubmit(String token, String userId, String batchNo) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("batchNo", batchNo);
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/trade/protocolTrade/submit", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("经理人导入数据提交>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("经理人导入数据提交通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 经理人协议交易查询
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject managerListPc(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/protocolTrade/managerListPc", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("经理人协议交易查询>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("经理人协议交易查询通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 经理人协议交易历史查询
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject managerListPcHis(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/protocolTrade/managerListPcHis", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("经理人协议交易历史查询>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("经理人协议交易历史查询通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 客户协议交易待确认列表查询
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject unconfirmedList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("commodity", commodity);商品（商品代码或名称）
//			params.put("managerId", managerId);经理人编号
//			params.put("managerNickName", managerNickName);经理人昵称
//			params.put("offset", 1000);查询偏移量，正值查询新增，负值查询过去数据
//			params.put("standard", standard);查询基准号，本服务中定义为申请编号
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/protocolTrade/unconfirmedList", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("客户协议交易待确认列表查询>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("客户协议交易待确认列表查询通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 客户协议交易列表查询（已确认和已取消）
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject protocolTradeList(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("offset", 1000);//查询偏移量，正值查询新增，负值查询过去数据
			params.put("pageNum", 1);//
			params.put("pageSize", 0);//
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/protocolTrade/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("客户协议交易列表查询（已确认和已取消）>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("客户协议交易列表查询（已确认和已取消）通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 历史客户协议交易列表查询（已确认和已取消）
	 *
	 * @param token
	 * @param userId
	 * @return
	 */
	public JSONObject protocolTradelistHis(String token, String userId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			params.put("offset", 1000);//查询偏移量，正值查询新增，负值查询过去数据
			params.put("pageNum", 1);//
			params.put("pageSize", 0);//
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/protocolTrade/listHis", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("历史客户协议交易列表查询（已确认和已取消）>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("历史客户协议交易列表查询（已确认和已取消）通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 协议交易确认
	 *
	 * @param token
	 * @param userId
	 * @param applyId
	 * @return
	 */
	public JSONObject protocolTradeConfirm(String token, String userId, String applyId, JSONObject jsonObject) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			headers.put("Content-Type", "application/json");
//			Map<String, Object> params = new HashMap<>();
//			params.put("applyId", applyId);//applyId
			//protocolTradeConfirmVO={"addressId":0,"applyId":0,"bankId":0,"bankNO":"","callbackUrl":"","payType":0,"tradeType":0,"type":"1"}
//			params.put("protocolTradeConfirmVO", jsonObject);//protocolTradeConfirmVO
			jsonObject.put("callbackUrl", "");
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/trade/protocolTrade/confirm/" + applyId, headers, jsonObject, "UTF-8");

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("协议交易确认>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("协议交易确认通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 挂单
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject tradeSale(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("commodityId", commodityId);//商品代码
//			params.put("price", price);//价格
//			params.put("quantity", quantity);//数量
			HttpClientResult result = httpClient.doPost(znApiUrl + "/sale/trade/trade/sale", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("挂单>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("挂单通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询发布
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject makerRecordList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("offset", 1000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/tradeQuery/makerRecord/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询发布>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询发布通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查询发布历史
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject makerRecordListHis(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
//			params.put("offset", 1000);
			HttpClientResult result = httpClient.doGet(znApiUrl + "/sale/trade/tradeQuery/makerRecord/listHis", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查询发布历史>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查询发布历史通信失败，请稍后重试或联系客服!");
		}
	}


	/**
	 * 物流信息查询
	 *
	 * @param token
	 * @param userId
	 * @param deliveryApplyId
	 * @return
	 */
	public JSONObject deliveryTrace(String token, String userId, String deliveryApplyId) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPut(znApiUrl + "/sale/delivery/shipping/deliveryTrace/" + deliveryApplyId, headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("物流信息查询>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("物流信息查询通信失败，请稍后重试或联系客服!");
		}
	}

	/**
	 * 查找账单流水
	 *
	 * @param token
	 * @param userId
	 * @param params
	 * @return
	 */
	public JSONObject fundsFlowQueryList(String token, String userId, Map<String, Object> params) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			headers.put("Token", token);
			headers.put("UserID", userId);
//			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doGet(znApiUrl + "/base/finance/fundsFlowQuery/list", headers, params);

			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
//			returnJson.put("content", JSONObject.parseObject(result.getContent()));
			returnJson.put("content", returnObject(result.getContent()));
			if (200 != result.getCode() && errorCode.get(returnJson.getJSONObject("content").getString("code")) != null) {
				returnJson.getJSONObject("content").put("msg", errorCode.get(returnJson.getJSONObject("content").getString("code")));
			}
			System.out.println("查找账单流水>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
			throw new ServiceException("查找账单流水通信失败，请稍后重试或联系客服!");
		}
	}

	public static Object returnObject(String content) {
		if (content.length() == 0) content = "{}";
		if (isJsonArray(content)) {
			return JSONArray.parseArray(content);
		} else if (isJsonObject(content)) {
			return JSONObject.parseObject(content);
		} else {
			return content;
		}
	}

	/**
	 * 判断字符串是否可以转化为json对象
	 *
	 * @param content
	 * @return
	 */
	public static boolean isJsonObject(String content) {
		if (Func.isBlank(content)) return false;
		try {
			// JSONObject jsonStr =
			JSONObject.parseObject(content);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	/**
	 * 判断字符串是否可以转化为JSON数组
	 *
	 * @param content
	 * @return
	 */
	public static boolean isJsonArray(String content) {
		if (Func.isBlank(content)) return false;
		Func.isEmpty(content);
		try {
			//JSONObject jsonStr =
			JSONArray.parseArray(content);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	private final static Map<String, String> errorCode = new HashMap<>();

	static {
		errorCode.put("-337010000010", "系统未启动完成");
		errorCode.put("-337010000020", "登录验证失效");
		errorCode.put("-337010000030", "登录用户代码为空");
		errorCode.put("-337010000040", "登录用户与传入用户不一致");
		errorCode.put("-337010000050", "支付对象为空");
		errorCode.put("-337010000060", "回调的url为空");
		errorCode.put("-337010000070", "客户端类型为空");
		errorCode.put("-337010000080", "快捷支付没有签约");
		errorCode.put("-337010000980", "数据库异常");
		errorCode.put("-337010000990", "系统异常");
		errorCode.put("-337010010010", "用户代码为空");
		errorCode.put("-337010010020", "银行卡号为空");
		errorCode.put("-337010010030", "真实姓名为空");
		errorCode.put("-337010010040", "证件类型为空");
		errorCode.put("-337010010050", "证件号为空");
		errorCode.put("-337010010060", "超级网银号为空");
		errorCode.put("-337010010070", "手机号为空");
		errorCode.put("-337010010080", "法人姓名为空");
		errorCode.put("-337010010090", "法人证件类型为空");
		errorCode.put("-337010010100", "法人证件号码为空");
		errorCode.put("-337010020010", "绑定银行卡记录编号为空");
		errorCode.put("-337010020020", "验证码为空");
		errorCode.put("-337010030010", "银行卡号为空");
		errorCode.put("-337011010010", "寄存对象为空");
		errorCode.put("-337011010020", "寄存计划编号为空");
		errorCode.put("-337011010030", "用户代码为空");
		errorCode.put("-337011010040", "申请数量必须大于0");
		errorCode.put("-337011010050", "预约时间为空");
		errorCode.put("-337011010060", "支付方式为空");
		errorCode.put("-337011011010", "寄存信息不存在");
		errorCode.put("-337011011020", "不在寄存时间");
		errorCode.put("-337011011030", "不满足最小寄存数量");
		errorCode.put("-337011011040", "寄存商品部存在");
		errorCode.put("-337011011050", "寄存手续费计算错误");
		errorCode.put("-337011011060", "余额不足");
		errorCode.put("-337011011070", "调用三方支付失败");
		errorCode.put("-337011011080", "自备商品只允许该商品经理人申请");
		errorCode.put("-337011020010", "传入托管计划编号为空");
		errorCode.put("-337011021010", "寄存申请不存在");
		errorCode.put("-337011021020", "只能撤销自己的寄存申请");
		errorCode.put("-337011021030", "寄存申请状态不是申请状态");
		errorCode.put("-337011021040", "寄存申请正在支付中");
		errorCode.put("-337011021050", "寄存商品不存在");
		errorCode.put("-337011021060", "寄存退款手续费大于总手续费");
		errorCode.put("-337011030010", "寄存申请编号为空");
		errorCode.put("-337011030020", "实际寄存数量必须大于0");
		errorCode.put("-337011031010", "寄存申请不存在");
		errorCode.put("-337011031020", "寄存申请状态不是申请状态");
		errorCode.put("-337011031030", "寄存申请正在支付中");
		errorCode.put("-337011031040", "实际寄存数量不能大于申请数量");
		errorCode.put("-337011031050", "寄存计划不存在");
		errorCode.put("-337011031060", "寄存商品不存在");
		errorCode.put("-337011031070", "寄存退款手续费大于总手续费");
		errorCode.put("-337011040010", "寄存申请编号为空");
		errorCode.put("-337011041010", "寄存申请不存在");
		errorCode.put("-337011041020", "寄存申请状态不是申请状态");
		errorCode.put("-337011041030", "寄存申请正在支付中");
		errorCode.put("-337011041040", "寄存商品不存在");
		errorCode.put("-337011041050", "寄存退款手续费大于总手续费");
		errorCode.put("-337011111010", "支付流水不存在");
		errorCode.put("-337011111020", "寄存申请不存在");
		errorCode.put("-337011111030", "寄存申请状态不是申请状态");
		errorCode.put("-337011121010", "寄存申请调用三方退款异常");
		errorCode.put("-337011121020", "寄存申请退款结果处理异常");
		errorCode.put("-337011131010", "退款流水不存在");
		errorCode.put("-337011131020", "寄存申请不存在");
		errorCode.put("-337011131030", "寄存申请状态不是取消中或者通过中或者驳回中");
		errorCode.put("-337012010010", "交收申请对象为空");
		errorCode.put("-337012010020", "用户代码为空");
		errorCode.put("-337012010030", "商品代码为空");
		errorCode.put("-337012010040", "申请数量必须大于0");
		errorCode.put("-337012010050", "地址编号不能为空");
		errorCode.put("-337012010060", "支付方式不能为空");
		errorCode.put("-337012011010", "交收商品不存在");
		errorCode.put("-337012011020", "未到提货日期");
		errorCode.put("-337012011030", "收货地址编号不存在");
		errorCode.put("-337012011040", "持仓不足");
		errorCode.put("-337012011050", "余额不足");
		errorCode.put("-337012011060", "调用三方支付失败");
		errorCode.put("-337012020010", "交收申请编号为空");
		errorCode.put("-337012021010", "");
		errorCode.put("-337012021020", "交收申请撤销失败， 状态不是申请中");
		errorCode.put("-337012021030", "交收申请撤销失败，提货申请数量必须大于0");
		errorCode.put("-337012021040", "交收申请撤销失败，可提货量不足");
		errorCode.put("-337012021050", "交收申请撤销失败，不是自己的提货申请，不能取消");
		errorCode.put("-337012021060", "交收申请撤销失败，业务类型不存在");
		errorCode.put("-337012021070", "交收申请撤销失败，用户不存在");
		errorCode.put("-337012030010", "交收申请编号为空");
		errorCode.put("-337012031010", "交收申请不存在");
		errorCode.put("-337012031020", "交收申请不允许撤销");
		errorCode.put("-337012031030", "交收申请状态不是申请状态");
		errorCode.put("-337012031040", "交收申请正在支付中");
		errorCode.put("-337012031050", "寄存商品不存在");
		errorCode.put("-337012031060", "交收退款手续费大于总手续费");
		errorCode.put("-337012040010", "交收申请编号为空");
		errorCode.put("-337012041010", "交收申请不存在");
		errorCode.put("-337012041020", "交收申请状态不是配送状态");
		errorCode.put("-337012041030", "商品信息不存在");
		errorCode.put("-337012041040", "调用三方解冻失败");
		errorCode.put("-337012111010", "支付流水不存在");
		errorCode.put("-337012111020", "交收申请不存在");
		errorCode.put("-337012111030", "交收申请状态不是申请状态");
		errorCode.put("-337012121010", "交收申请调用三方退款异常");
		errorCode.put("-337012121020", "交收申请退款结果处理异常");
		errorCode.put("-337012131010", "退款流水不存在");
		errorCode.put("-337012131020", "交收申请不存在");
		errorCode.put("-337012131030", "交收申请状态不是取消中或者驳回中");
		errorCode.put("-337013010010", "挂单，买卖标识不符");
		errorCode.put("-337013010020", "挂单，价格为空");
		errorCode.put("-337013010030", "挂单，数量为空");
		errorCode.put("-337013010040", "挂单，商品信息不存在");
		errorCode.put("-337013010050", "挂单，商品暂停交易");
		errorCode.put("-337013010060", "买挂单，资金不足");
		errorCode.put("-337013011010", "商品信息不存在");
		errorCode.put("-337013011020", "商品不允许交易");
		errorCode.put("-337013011030", "收货地址编号不存在");
		errorCode.put("-337013011040", "可摘单数量不足，请重试");
		errorCode.put("-337013011050", "余额不足");
		errorCode.put("-337013011060", "调用三方支付失败");
		errorCode.put("-337013011070", "自备商品只能提货");
		errorCode.put("-337013111010", "支付流水不存在");
		errorCode.put("-337013111020", "摘单记录不存在");
		errorCode.put("-337013111030", "商品信息不存在");
		errorCode.put("-337013111040", "摘单明细不存在");
		errorCode.put("-337014010010", "摘单失败：摘单信息不存在");
		errorCode.put("-337014010020", "摘单失败：该挂单已经成交或撤单");
		errorCode.put("-337014010030", "摘单失败：摘单数量超出挂单数量");
		errorCode.put("-337014011010", "协议交易记录不存在");
		errorCode.put("-337014011020", "协议交易状态不是市场审核通过");
		errorCode.put("-337014011030", "协议交易正在支付中");
		errorCode.put("-337014011040", "商品信息不存在");
		errorCode.put("-337014011050", "商品不允许交易");
		errorCode.put("-337014011060", "收货地址信息不存在");
		errorCode.put("-337014011070", "余额不足");
		errorCode.put("-337014011080", "调用三方支付失败");
		errorCode.put("-337014111010", "支付流水不存在");
		errorCode.put("-337014111020", "协议交易记录不存在");
		errorCode.put("-337014111030", "商品信息不存在");
		errorCode.put("-337014111040", "协议交易记录状态不是用户确认中");
		errorCode.put("-337015010010", "银行卡号为空");
		errorCode.put("-337015010020", "提现金额必须大于0");
		errorCode.put("-337015011010", "调用三方接口异常");
		errorCode.put("-337015011020", "调用三方接口失败");
		errorCode.put("-337015111010", "提现流水不存在");
		errorCode.put("-337016010010", "签约申请信息为空");
		errorCode.put("-337016010020", "签约申请信息用户代码为空");
		errorCode.put("-337016010030", "签约申请信息银行卡号为空");
		errorCode.put("-337016010040", "签约申请信息银行卡账户名为空");
		errorCode.put("-337016010050", "签约申请信息超级网银号为空");
		errorCode.put("-337016010060", "签约申请信息设备类型为空");
		errorCode.put("-337016010070", "签约申请信息前台跳转地址为空");
		errorCode.put("-337016010080", "签约申请信息证件号码为空");
		errorCode.put("-337016010090", "签约申请信息证件类型为空");
		errorCode.put("-337016010100", "签约申请信息手机号为空");
		errorCode.put("-337016011010", "签约申请记录不存在");
		errorCode.put("-337016011020", "协议支付签约调用三方失败");
		errorCode.put("-337016020010", "支付记录为空");
		errorCode.put("-337016020020", "订单号为空");
		errorCode.put("-337016020030", "订单类型为空");
		errorCode.put("-337016020040", "支付验证码为空");
		errorCode.put("-337016021010", "支付记录为空");
		errorCode.put("-337016021020", "支付流水状态不是未支付");
		errorCode.put("-337016021030", "签约信息为空");
		errorCode.put("-337016021040", "商品信息为空");
		errorCode.put("-337016021050", "协议支付调用三方失败");
		errorCode.put("-201029999990", "安全密码错误，连续错误%d次后将被锁定，已错误%d次");
		errorCode.put("-201029999991", "安全密码已被锁定，请%d分钟后重试");
		errorCode.put("-201029999996", "账号不能包含非法字符");
		errorCode.put("-201029999997", "验证信息为空，验证安全密码失败");
		errorCode.put("-201029999998", "验证安全密码失败");
		errorCode.put("-201029999999", "数据库异常");
		errorCode.put("-201021010010", "此收付款方式已存在，请勿重复添加");
		errorCode.put("-201021010020", "您尚未实名，请实名后添加");
		errorCode.put("-201021010030", "当支付类型选择银行卡时，银行名称不能为空");
		errorCode.put("-201021020010", "删除的收付款方式不存在");
		errorCode.put("-201021030010", "用户信息不匹配，不能修改");
		errorCode.put("-201021030020", "收付款方式已存在");
		errorCode.put("-201021050010", "充值申请，参数传入错误");
		errorCode.put("-201021050020", "银行充值时，银行名为空");
		errorCode.put("-201021050030", "充值申请，传入的收付款方ID错误");
		errorCode.put("-201021050040", "当充值类型选择银行卡时，银行名称不能为空");
		errorCode.put("-201021050041", "请输入正确的充值金额");
		errorCode.put("-201021080010", "提现申请，参数传入错误");
		errorCode.put("-201021080020", "提现申请，银行提现时，银行名为空");
		errorCode.put("-201021080030", "提现申请，传入的收付款方式ID错误");
		errorCode.put("-201021080040", "提现申请失败：用户不存在");
		errorCode.put("-201021080050", "提现申请失败：收付款方式不存在");
		errorCode.put("-201021080060", "提现申请失败：不可以使用其他用户的收付款信息");
		errorCode.put("-201021080070", "提现申请失败：超过单笔限额");
		errorCode.put("-201021080080", "提现申请失败：超过当日总限额");
		errorCode.put("-201021080090", "提现申请失败：余额不足");
		errorCode.put("-201021080110", "提现申请失败：业务类型不存在");
		errorCode.put("-201021080120", "提现申请失败：余额不足");
		errorCode.put("-201021080130", "提现申请失败：解冻资金不足");
		errorCode.put("-201021090010", "获取手续费率失败");
		errorCode.put("-200011030010", "账号或密码错误，请重新输入！");
		errorCode.put("-200011040010", "手机号已注册!");
		errorCode.put("-200011050010", "手机号已存在");
		errorCode.put("-200011050020", "实名验证失败");
		errorCode.put("-200011050030", "客户信息为空");
		errorCode.put("-200011050040", "原密码不正确");
		errorCode.put("-200011050050", "客户实名信息为空");
		errorCode.put("-200011060010", "发送验证码失败");
		errorCode.put("-200011060020", "验证码错误");
		errorCode.put("-200011070010", "用户有资金不允许注销");
		errorCode.put("-200011080010", "已存在实名申请信息，请勿重复操作！");
		errorCode.put("-200011080020", "已实名，请勿重复操作！");
		errorCode.put("-200011080030", "证件号码已存在！");
		errorCode.put("-200011090010", "姓名不能为空");
		errorCode.put("-200011090020", "证件号不能为空");
		errorCode.put("-200011090030", "银行卡号不能为空");
		errorCode.put("-200011090040", "手机号不能为空");
		errorCode.put("-200011090050", "调用核心异常");
		errorCode.put("-200011090060", "绑定信息不存在");
		errorCode.put("-200011100010", "用户不是普通用户");
		errorCode.put("-200011100020", "用户信息不存在");
		errorCode.put("-200001010010", "您尚未登录或登录超时，请重新登录后操作！");
		errorCode.put("-200001010020", "由于您长时间没有操作，造成身份失效，请重新登录!");
		errorCode.put("-200001010030", "您的账号在其他设备登录，您被迫下线!");
		errorCode.put("-200001020010", "您的权限不足，无法访问资源!");
		errorCode.put("-200001030010", "密码错误，连续错误%d次后将被锁定，已错误%d次");
		errorCode.put("-200001030020", "密码错误次数过多，账号被锁定，请%s分钟后重试！");
		errorCode.put("-200001030030", "密码错误次数过多，账号被锁定，请%s分钟后重试！");
		errorCode.put("-200001030040", "账户已注销，请联系平台!");
		errorCode.put("-200001030050", "您的账号处于冻结状态，请联系管理员！");
		errorCode.put("-200001030060", "登录失败!");
		errorCode.put("-201500001010", "聚合支付未知异常");
		errorCode.put("-201500001020", "用户未实名");
		errorCode.put("-201500001030", "数据库异常");
		errorCode.put("-201500011030", "金额不能小于最小充值金额");
		errorCode.put("-201500021010", "用户资金不存在");
		errorCode.put("-201500021020", "可用余额不足");
		errorCode.put("-237009991010", "冻结或解冻资金时失败【业务类型不存在】");
		errorCode.put("-237009991020", "冻结或解冻资金时失败：用户不存在");
		errorCode.put("-237009991030", "冻结或解冻资金时失败：余额不足");
		errorCode.put("-237009991040", "冻结或解冻资金时失败：解冻资金不足");
		errorCode.put("-237009992010", "写资金流水失败【发生额不能小于0】");
		errorCode.put("-237009992020", "写资金流水失败【业务类型不存在】");
		errorCode.put("-237009992030", "写资金流水失败【用户不存在】");
		errorCode.put("-237009992040", "写资金流水失败【余额不足】");
		errorCode.put("-237009999999", "冻结或解冻资金时失败【数据库异常】");
		errorCode.put("-237000001010", "交易暂停");
		errorCode.put("-237000001020", "三方处理失败");
		errorCode.put("-237000001030", "支付流水不存在");
		errorCode.put("-237000001040", "退款流水不存在");
		errorCode.put("-237000001050", "调用核心异常");
		errorCode.put("-237000001060", "");
		errorCode.put("-237000001070", "");
		errorCode.put("-237000001080", "");
		errorCode.put("-237000001090", "");
		errorCode.put("-237001011010", "传入托管计划编号为空");
		errorCode.put("-237001011020", "传入托管数量为空");
		errorCode.put("-237001011030", "托管计划不存在");
		errorCode.put("-237001011040", "托管申请失败:不在托管时间段内");
		errorCode.put("-237001011050", "银行卡信息不存在");
		errorCode.put("-237001011060", "银行卡ID和超级网银号不能为空");
		errorCode.put("-237001020010", "托管申请编号为空");
		errorCode.put("-237001020020", "托管申请信息不存在");
		errorCode.put("-237001020030", "托管申请失败，只能撤销自己的托管申请记录");
		errorCode.put("-237001020040", "托管申请记录状态不是申请，撤销失败");
		errorCode.put("-237001020050", "托管撤销失败，退款金额大于支付金额");
		errorCode.put("-237002010010", "交收申请失败：收货地址编号不存在");
		errorCode.put("-237002010020", "交收申请失败：可提货量不足");
		errorCode.put("-237002010030", "交收申请失败：业务类型不存在");
		errorCode.put("-237002010040", "交收申请失败：用户不存在");
		errorCode.put("-237002010050", "交收申请失败：余额不足");
		errorCode.put("-237002010060", "交收申请失败：解冻资金不足");
		errorCode.put("-237002010070", "交收申请失败：业务类型不存在");
		errorCode.put("-237002010080", "交收申请失败：银行卡信息不存在");
		errorCode.put("-237002010090", "银行卡ID和超级网银号不能为空");
		errorCode.put("-237002020010", "交收申请撤销失败，提货申请记录不存在");
		errorCode.put("-237002020020", "交收申请撤销失败， 状态不是申请中");
		errorCode.put("-237002020030", "交收申请撤销失败，提货申请数量必须大于0");
		errorCode.put("-237002020040", "交收申请撤销失败，可提货量不足");
		errorCode.put("-237002020050", "交收申请撤销失败，不是自己的提货申请，不能取消");
		errorCode.put("-237002020060", "交收申请撤销失败，业务类型不存在");
		errorCode.put("-237002020070", "交收申请撤销失败，用户不存在");
		errorCode.put("-237002020080", "交收申请撤销失败，余额不足");
		errorCode.put("-237002020090", "交收申请撤销失败，解冻资金不足");
		errorCode.put("-237002020100", "交收申请撤销失败，数据库异常");
		errorCode.put("-237003010010", "挂单，买卖标识不符");
		errorCode.put("-237003010020", "挂单，价格为空");
		errorCode.put("-237003010030", "挂单，数量为空");
		errorCode.put("-237003010040", "挂单，商品信息不存在");
		errorCode.put("-237003010050", "挂单，商品暂停交易");
		errorCode.put("-237003010060", "买挂单，资金不足");
		errorCode.put("-237003010070", "买挂单，价格应小于卖最低价");
		errorCode.put("-237003010080", "卖挂单，没有该商品持仓");
		errorCode.put("-237003010090", "卖挂单，持仓不足");
		errorCode.put("-237003010100", "卖挂单，价格应大于买最高价");
		errorCode.put("-237003010110", "挂单，商品未上市");
		errorCode.put("-237003010120", "挂单失败：下单价格超出涨幅上限");
		errorCode.put("-237003010130", "挂单失败：下单价格小于跌幅下限");
		errorCode.put("-237003010140", "挂单失败：价格不是最小变动价整数倍");
		errorCode.put("-237003020010", "撤单时撤单编号为空");
		errorCode.put("-237003020020", "撤单失败：撤单记录不存在");
		errorCode.put("-237003020030", "撤单失败：用户信息与撤单中用户信息不一致");
		errorCode.put("-237003020040", "撤单失败：该挂单状态不允许撤单");
		errorCode.put("-237003030010", "摘单失败：摘单信息不存在");
		errorCode.put("-237003030020", "摘单失败：该挂单已经成交或撤单");
		errorCode.put("-237003030030", "摘单失败：摘单数量超出挂单数量");
		errorCode.put("-237003030040", "摘单失败，商品暂停交易");
		errorCode.put("-237003030050", "摘单失败，不能摘自己的挂单记录");
		errorCode.put("-237003030060", "摘单失败，存在价格更优的买挂单记录");
		errorCode.put("-237003030070", "摘单失败，存在价格更优的卖挂单记录");
		errorCode.put("-237003030080", "摘单失败，挂单编号为空");
		errorCode.put("-237003030090", "摘单失败，数量为空");
		errorCode.put("-237003030110", "摘单失败，商品未上市");
		errorCode.put("-237003030120", "摘单失败，资金不足");
		errorCode.put("-237003040010", "操作失败没有可买持仓");
		errorCode.put("-237003040020", "卖出失败，可买数量不足");
		errorCode.put("-237003040030", "银行卡信息不存在");
		errorCode.put("-237003040040", "卖出失败，商品已下架");
		errorCode.put("-237003040050", "卖出失败，卖出价大于最高价");
		errorCode.put("-237003040060", "卖出失败，卖出价小于最低价");
		errorCode.put("-237003050010", "申请记录不存在");
		errorCode.put("-237003050020", "已存在申请记录不可重复添加");
		errorCode.put("-237003060010", "商品信息不存在");
		errorCode.put("-237003060020", "只有三方仓库商品才可以进行协议交易申请");
		errorCode.put("-237003060030", "用户不属于经理人");
		errorCode.put("-237003060040", "商品不属于经理人");
		errorCode.put("-237003060050", "可用数量不足");
		errorCode.put("-237003060060", "用户的批次号的协议交易申请已存在");
		errorCode.put("-237003060070", "交易编号不存在");
		errorCode.put("-237003060080", "交易方式不正确");
		errorCode.put("-237003060090", "支付方式不正确");
		errorCode.put("-237003060110", "银行卡信息不存在");
		errorCode.put("-237003060120", "银行卡ID和超级网银号不能为空");
		errorCode.put("-237003060130", "商品不是有效状态");
		errorCode.put("-237003060140", "不是有效的整数");
		errorCode.put("-237003060150", "价格最多只能两位小数");
		errorCode.put("-237003070010", "交易方式不正确");
		errorCode.put("-237003070020", "支付方式不正确");
		errorCode.put("-237003070030", "银行卡信息不存在");
		errorCode.put("-237003070040", "银行卡ID和超级网银号不能为空");
		errorCode.put("-237003070050", "购买失败，商品已下架");
		errorCode.put("-100012070010", "原密码错误！");
		errorCode.put("-100011010010", "用户名%s已存在！");
		errorCode.put("-100011010020", "手机号%s已存在！");
		errorCode.put("-100011020010", "角色名称%s已存在！");
		errorCode.put("-100011030010", "验证角色名称不存在");
		errorCode.put("-100011040010", "修改管理员[%s]密码失败，原密码错误");
		errorCode.put("-100011050010", "");
		errorCode.put("-101031000010", "板块名称已存在");
		errorCode.put("-101031000020", "资讯记录不存在");
		errorCode.put("-101031000030", "资讯已删除");
		errorCode.put("-101031010010", "资讯不是审核通过状态，不能修改");
		errorCode.put("-101031010020", "");
		errorCode.put("-101031020010", "审核驳回，备注信息不能为空");
		errorCode.put("-101031020020", "资讯已审核，不能重复审核");
		errorCode.put("-101031020030", "");
		errorCode.put("-101031030030", "审核驳回状态下的资讯不能删除");
		errorCode.put("-101031030040", "");
		errorCode.put("-101041000010", "公告记录不存在");
		errorCode.put("-101041000020", "公告已删除");
		errorCode.put("-101041000030", "");
		errorCode.put("-101041010010", "公告不是审核通过状态，不允许修改");
		errorCode.put("-101041010020", "");
		errorCode.put("-101041020010", "公告申请已审核通过");
		errorCode.put("-101041020020", "公告申请已审核驳回");
		errorCode.put("-100031031010", "用户注销申请记录不存在，申请编号： %s");
		errorCode.put("-100031040010", "客户实名申请信息为空，申请编号： %s");
		errorCode.put("-100031040020", "已处理，请勿重复操作");
		errorCode.put("-100031040030", "证件号已使用");
		errorCode.put("-100031041010", "客户实名申请信息为空，申请编号： %s");
		errorCode.put("-100031041020", "已处理，请勿重复操作");
		errorCode.put("-100031050010", "通过云获取前置机地址失败");
		errorCode.put("-101019999999", "数据库异常");
		errorCode.put("-101011030010", "充值申请记录不存在");
		errorCode.put("-101011030020", "充值申请已审核通过或审核驳回");
		errorCode.put("-101011030030", "业务类型不存在");
		errorCode.put("-101011030040", "用户不存在");
		errorCode.put("-101011030050", "余额不足");
		errorCode.put("-101011030060", "解冻资金不足");
		errorCode.put("-101011030070", "发生额不能小于0");
		errorCode.put("-101011030080", "业务类型不存在");
		errorCode.put("-101011030090", "用户不存在");
		errorCode.put("-101011030100", "余额不足");
		errorCode.put("-101011030110", "解冻资金不足");
		errorCode.put("-101011060010", "提现申请记录不存在");
		errorCode.put("-101011060020", "提现申请已审核通过或审核驳回");
		errorCode.put("-101011060030", "业务类型不存在");
		errorCode.put("-101011060040", "用户不存在");
		errorCode.put("-101011060050", "余额不足");
		errorCode.put("-101011060060", "解冻资金不足");
		errorCode.put("-101011060070", "发生额不能小于0");
		errorCode.put("-101011060080", "业务类型不存在");
		errorCode.put("-101011060090", "用户不存在");
		errorCode.put("-101011060100", "余额不足");
		errorCode.put("-101011060110", "解冻资金不足");
		errorCode.put("-101011060120", "请输入提现流水号");
		errorCode.put("-101011060130", "请输入驳回原因");
		errorCode.put("-100001010010", "您尚未登录，请登录后操作!");
		errorCode.put("-100001010020", "身份已失效，请重新登录!");
		errorCode.put("-100001010030", "您的账号在其他设备登录，您被迫下线!");
		errorCode.put("-100001020010", "权限不足，请联系管理员！");
		errorCode.put("-100001030010", "账号或密码错误，请重新输入！");
		errorCode.put("-100001030020", "账户被锁定，请联系管理员!");
		errorCode.put("-100001030030", "密码过期，请联系管理员!");
		errorCode.put("-100001030040", "账户已注销，请联系平台!");
		errorCode.put("-100001030050", "账户被禁用，请联系管理员!");
		errorCode.put("-100001030060", "登录失败!");
		errorCode.put("-100001039960", "登录执行成功，返回结果失败！");
		errorCode.put("-137000010010", "非法的系统状态");
		errorCode.put("-137000010020", "此分类已存在商品, 不可删除");
		errorCode.put("-137000010030", "商品对象为空");
		errorCode.put("-137000010040", "商品ID被占用");
		errorCode.put("-137000010050", "找不到指定商品的详细信息");
		errorCode.put("-137000010060", "修改商品传入信息为空");
		errorCode.put("-137000010070", "未能获取到系统状态");
		errorCode.put("-137000010080", "未能获取到卖货周期设置");
		errorCode.put("-137000010090", "商品分类[%s]删除失败");
		errorCode.put("-137000010100", "开盘指导价必须是最小变动价位的整数倍");
		errorCode.put("-137000010110", "未能获取商品的上市时间");
		errorCode.put("-137000010120", "商品已经上市, 不能修改");
		errorCode.put("-137000010130", "开盘指导价必须大于0");
		errorCode.put("-137000010140", "最小变动价位必须大于0");
		errorCode.put("-137000010150", "商品ID不存在");
		errorCode.put("-137000010160", "下架失败，商品正在挂单中");
		errorCode.put("-137000010170", "下架失败，商品正在协议交易中");
		errorCode.put("-137000020010", "此托管计划已有申请, 不可删除");
		errorCode.put("-137000020020", "审核通过数量必须大于0");
		errorCode.put("-137000020030", "审核操作类型非法");
		errorCode.put("-137000020040", "托管计划[%s]删除失败");
		errorCode.put("-137000020050", "获取用户托管申请数据失败");
		errorCode.put("-137000020060", "获取用户持仓数据失败");
		errorCode.put("-137000020070", "托管计划已经开始, 不可删除");
		errorCode.put("-137000020080", "托管计划已经开始, 不可修改");
		errorCode.put("-137000020090", "审核通过数量不能大于申请数量");
		errorCode.put("-137000030010", "提货申请记录不存在");
		errorCode.put("-137000030020", "提货申请状态不是申请中");
		errorCode.put("-137000030030", "提货申请数量必须大于0");
		errorCode.put("-137000030040", "可提货数量不足");
		errorCode.put("-137000030050", "不能取消他人的提货申请");
		errorCode.put("-137000030060", "业务类型不存在");
		errorCode.put("-137000030070", "用户不存在");
		errorCode.put("-137000030080", "余额不足");
		errorCode.put("-137000030090", "解冻资金不足");
		errorCode.put("-137000030100", "发生额不能小于0");
		errorCode.put("-137000030990", "提货审核未知异常");
		errorCode.put("-137000040010", "");
		errorCode.put("-137000050010", "");
		errorCode.put("-137000060010", "申请信息不存在");
		errorCode.put("-137000060020", "不是申请中的状态");
		errorCode.put("-137000060030", "传入自动协议交易参数为空");
		errorCode.put("-137000060040", "商品ID不存在");
		errorCode.put("-137000060050", "商品状态不正常");
		errorCode.put("-137000060060", "协议交易商品不属于经理人");
		errorCode.put("-137000060070", "协议交易商品ID不存在");
		errorCode.put("-137000060080", "协议交易商品状态不正常");
		errorCode.put("-137000060090", "商品已存在相同交易方向的参数设置");
		errorCode.put("-137000070010", "售后信息不存在");
		errorCode.put("-137000070020", "售后信息不是未处理状态");
		errorCode.put("-994000010010", "生成发送信息失败");
		errorCode.put("-994000010020", "生成接收人失败");
		errorCode.put("-994000010030", "发送通知失败");
		errorCode.put("-409091000001", "RMI校验失败");
		errorCode.put("-409091000002", "缺失参数");
		errorCode.put("-409091000020", "请求银行失败");
		errorCode.put("-409091000021", "请求银行失败，原因未知");
		errorCode.put("-409091000998", "请求银行系统异常");
		errorCode.put("-409091000999", "系统异常");
		errorCode.put("-409091010010", "开户申请中");
		errorCode.put("-409091020010", "开户信息不存在");
		errorCode.put("-409091020011", "状态不是已开户");
		errorCode.put("-409091030010", "解绑处理中");
		errorCode.put("-409091030011", "用户类型不正确");
		errorCode.put("-409091030020", "还未开户成功");
		errorCode.put("-409091030030", "需要先发起绑定申请");
		errorCode.put("-409091040010", "没有绑定关系");
		errorCode.put("-409091040020", "没有绑卡成功");
		errorCode.put("-409091050010", "金额非法");
		errorCode.put("-409091050020", "还未开户");
		errorCode.put("-409091050030", "已销户");
		errorCode.put("-409091050040", "银行返回信息有误");
		errorCode.put("-409091050050", "提现记录不存在");
		errorCode.put("-409091050060", "提现申请编号已存在");
		errorCode.put("-409091050070", "该银行卡没有绑定成功");
		errorCode.put("-409091060010", "支付申请编号已存在");
		errorCode.put("-409091060020", "收款方未开户");
		errorCode.put("-409091060030", "银行编号为空");
		errorCode.put("-409091060040", "支付申请记录不存在");
		errorCode.put("-409091060050", "子订单金额合计大于订单金额");
		errorCode.put("-409091060060", "验证码错误（可以原订单号重新发起）");
		errorCode.put("-409091070010", "原支付明细记录不存在");
		errorCode.put("-409091070011", "原支付没有冻结");
		errorCode.put("-409091070012", "订单没有支付成功");
		errorCode.put("-409091070013", "该笔子订单已被解冻");
		errorCode.put("-409091070014", "没有查询到收款方的开户信息");
		errorCode.put("-409091080010", "退款申请编号已存在");
		errorCode.put("-409091080020", "退款申请中");
		errorCode.put("-409091080030", "退款申请失败，原因参考remark");
		errorCode.put("-409091080040", "没有支付申请记录");
		errorCode.put("-409091080041", "原支付申请没有成功");
		errorCode.put("-409091080050", "没有支付子订单记录");
		errorCode.put("-409091080051", "累计退款金额大于原子订单金额");
		errorCode.put("-409091080060", "退款人无开户记录");
		errorCode.put("-990030010010", "请求参数校验不通过！");
		errorCode.put("-990030010020", "请求参数不能为空！");
		errorCode.put("-990030010030", "分页参数错误！");
		errorCode.put("-990030010040", "服务端校验参数不通过！");
		errorCode.put("-990031010010", "不允许的文件类型%s！");
		errorCode.put("-990031010020", "找不到文件%s!");
		errorCode.put("-993000010010", "重发间隔时间短，请稍后重发！");
	}

	/*
	 * 随机生成国内IP地址
	 */
	public static String getRandomIp() {
		//ip范围
		int[][] range = {{607649792, 608174079},//36.56.0.0-36.63.255.255
			{1038614528, 1039007743},//61.232.0.0-61.237.255.255
			{1783627776, 1784676351},//106.80.0.0-106.95.255.255
			{2035023872, 2035154943},//121.76.0.0-121.77.255.255
			{2078801920, 2079064063},//123.232.0.0-123.235.255.255
			{-1950089216, -1948778497},//139.196.0.0-139.215.255.255
			{-1425539072, -1425014785},//171.8.0.0-171.15.255.255
			{-1236271104, -1235419137},//182.80.0.0-182.92.255.255
			{-770113536, -768606209},//210.25.0.0-210.47.255.255
			{-569376768, -564133889}, //222.16.0.0-222.95.255.255
		};
		Random rdint = new Random();
		int index = rdint.nextInt(10);
		String ip = num2ip(range[index][0] + new Random().nextInt(range[index][1] - range[index][0]));
		return ip;
	}

	/*
	 * 将十进制转换成ip地址
	 */
	public static String num2ip(int ip) {
		int[] b = new int[4];
		String x = "";
		b[0] = (int) ((ip >> 24) & 0xff);
		b[1] = (int) ((ip >> 16) & 0xff);
		b[2] = (int) ((ip >> 8) & 0xff);
		b[3] = (int) (ip & 0xff);
		x = Integer.toString(b[0]) + "." + Integer.toString(b[1]) + "." + Integer.toString(b[2]) + "." + Integer.toString(b[3]);
		return x;
	}

	/**
	 * 分配二级解冻资格
	 *
	 * @param mobilePhone 手机号,不允许为空
	 */
	public JSONObject brokerageTwoStatus(String tenantId, String mobilePhone) {
		try {
			HttpClient httpClient = new HttpClient();
			Map<String, Object> headers = new HashMap<>();
			Map<String, Object> params = new HashMap<>();
			HttpClientResult result = httpClient.doPost(shqyUrl + "/api/lyUser/brokerageTwoStatus/" + mobilePhone, headers, params);
			System.out.println("分配二级解冻资格>>>>>>>>>：" + result);
			JSONObject returnJson = new JSONObject();
			returnJson.put("status", result.getCode());
			returnJson.put("content", returnObject(result.getContent()));
			System.out.println("分配二级解冻资格>>>>>>>>>：" + returnJson);
			return returnJson;
		} catch (Exception e) {
//			throw new ServiceException("分配二级解冻资格通信失败，请稍后重试或联系客服!");
			System.out.println("分配二级解冻资格通信失败，请稍后重试或联系客服!");
		}
		return new JSONObject();
	}
}
